<?php 
App::uses('AppController', 'Controller');

class ShopController extends AppController {
	
	public function index() {
		$this->loadModel('RootCategory');
		$this->set('title_for_layout', 'Gian hàng');
		// Load PostModel
		$this->loadModel("Shop");
		$data = $this->Shop->findAllTotalShop();
		$this->set('data', $data);

		$count_root_categories = count($this->RootCategory->findAllData());
		$num_col = 3;// Default number column divide is 3
		$num_col_div = number_format($count_root_categories / $num_col);

		$num_temp = $count_root_categories - ($num_col_div * 2);

		if($num_temp > $num_col_div){
			if(($num_temp + $num_col_div) % 2 == 0){
				$num_col_div = ($num_temp + $num_col_div) / 2;
			}else{
				$num_col_div = $num_temp;
			}
		}
		
		$this->set('num_col_div', $num_col_div);
	}	
}
?>